package com.ruoyi.common.utils.payment.dongwopay;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.parser.Feature;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.ruoyi.common.utils.MD5Util;

public class DongWoPayUtils {

    public static String key = "NYApKFYLWsIHi1Baq9JKnPqm5D7t43RN";


    public static String getSign(long time,String url,String version, JSONObject jsonObject){
        String sign = "";
        JSONObject ob = new JSONObject(true);
        ob.put("dwrsv",version);
        ob.put("requestTime",String.valueOf(time));
        String signStr = "POST"+url+time+ob.toJSONString()+JSONObject.toJSONString(jsonObject, SerializerFeature.WriteMapNullValue)+key;
//        System.out.println(signStr);
        sign = MD5Util.stringMD5(MD5Util.stringMD5(signStr));

        return sign;
    }

    public static void main(String[] args) {
        long reqtime =1733592402876l;
        String url = "/easyhome-app-application/shop/order/addShopOrderListBySeller";
        String key = "NYApKFYLWsIHi1Baq9JKnPqm5D7t43RN";
        JSONObject ob = new JSONObject(true);
        ob.put("dwrsv","2.0.18");
        ob.put("requestTime",reqtime);

        String data = "{\"pickupName\":\"\",\"pickupPhone\":\"13458586855\",\"deliveryType\":\"1\",\"campaignIds\":[],\"shopGuideId\":\"1021233497383866368\",\"shopGuideName\":\"林思铖\",\"shopGuidePhone\":\"18344983492\",\"goodsDetailsList\":[{\"goodsSkuId\":\"1022352147997777920\",\"shopId\":\"1021233472930324480\",\"goodsCode\":\"0000000202372335\",\"goodsId\":\"1022352147939057664\",\"goodsSkuTitle\":\"得高 地板 实木地板\",\"goodsTitle\":\"得高 地板 实木地板\",\"goodsPrice\":\"646\",\"goodsPic\":\"iOS/Resources/25D2E896-67F4-4B67-A9B8-ED7DF5A2A908-1732859323687_829x1007.jpg\",\"goodsPicUrl\":\"https://ossprod.jrdaimao.com/iOS/Resources/25D2E896-67F4-4B67-A9B8-ED7DF5A2A908-1732859323687_829x1007.jpg\",\"deliveryTime\":\"2024-12-10\",\"goodsNum\":1,\"skillGoods\":false,\"skillPrice\":null,\"skillOrgPrice\":\"599\",\"equityTagsMap\":null,\"realPrice\":\"646\",\"needCalSkillGoods\":false}],\"dmcouponIdSet\":[],\"acMemberId\":\"\",\"isMember\":1,\"memberId\":\"1025426634775527424\",\"phone\":\"13458586855\",\"linkedCampaignId\":\"\",\"useVCards\":[],\"redCouponIdSet\":[],\"registerFlag\":false,\"deliveryTime\":\"2024-12-10\",\"usePump\":false,\"orderPumpMoney\":\"\",\"validateCode\":\"\",\"selectEasyWorker\":false,\"deviceSource\":\"h5Business\",\"apiVersion\":\"2.1.6\",\"engineeringOrder\":false,\"contractType\":1}";
        JSONObject ob1 = JSONObject.parseObject(data, Feature.OrderedField);
        String sign =  getSign(reqtime,url,"2.0.18",ob1);
        System.out.println(sign);
    }
}
